﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Demos.DesignPatterns._14_解释器模式
{
    /// <summary>
    /// 非终结符表达式 - 与运算
    /// </summary>
    public class AndExpression: IExpression
    {
        private IExpression _left;
        private IExpression _right;
        public AndExpression(IExpression left, IExpression right)
        {
            _left = left;
            _right = right;
        }

        /// <summary>
        /// 解释与运算
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        public bool Interpret(Dictionary<string, bool> context)
        {
            return _left.Interpret(context) && _right.Interpret(context);
        }
    }
}
